#!/bin/bash

# LIMPIEZA CONFIGURACION PREVIA
./limpiezaInterfaces.sh

# ACTIVACION DE LA FUNCION DE ROUTER DEL SO
echo "1" >> /proc/sys/net/ipv4/ip_forward

# MASCARAS DE RED
Netmask24="255.255.255.0"
Netmask25="255.255.255.128"
Netmask26="255.255.255.192"
Netmask27="255.255.255.224"
Netmask28="255.255.255.240"
Netmask29="255.255.255.248"
Netmask30="255.255.255.252"

# INTERFACES
interfaz1=`ifconfig -a | egrep "eth." -o | head -1`
interfaz2=$interfaz1":0"

# IPS
IP1="10.74.63.245"
IP2="10.31.17.133"

# DIRECCIONES DE BROADCAST
BR1="10.74.63.247"
BR2="10.31.17.255"

# DIRECCIONES DE RED
sanAntonio="10.74.63.0"
lasConchas="10.74.63.192"
calchaqui="10.74.63.224"
uruguay="192.168.53.0"
acaraguay="10.31.17.0"
#chirimay="10.31.17.128"
uruguari="10.31.17.64"
iguazu="10.97.5.0"
parana="10.31.17.96"
gualeguay="10.74.57.0"
hernandarias="10.74.63.128"
bululu="10.74.63.240"
#nogoya="10.74.63.244"

# DIRECCIONES DE GATEWAY
porH116="10.74.63.246" #interfaz1
porH105="10.31.17.132" #interfaz2


# CONFIGURACION DE LAS INTERFACES DEL ROUTER
ifconfig $interfaz1 $IP1 broadcast $BR1 netmask $Netmask30 pointopoint $porH116
ifconfig $interfaz2 $IP2 broadcast $BR2 netmask $Netmask25

# CONFIGURACION DE LA TABLA DE RUTEO
route add -net $sanAntonio netmask $Netmask25 dev $interfaz1 metric 3 gw $porH116
route add -net $lasConchas netmask $Netmask27 dev $interfaz1 metric 3 gw $porH116
route add -net $calchaqui netmask $Netmask29 dev $interfaz1 metric 3 gw $porH116
route add -net $uruguay netmask $Netmask24 dev $interfaz1 metric 3 gw $porH116
route add -net $acaraguay netmask $Netmask26 dev $interfaz2 metric 2 gw $porH105
route add -net $uruguari netmask $Netmask27 dev $interfaz2 metric 1 gw $porH105
route add -net $iguazu netmask $Netmask24 dev $interfaz2 metric 2 gw $porH105
route add -net $parana netmask $Netmask27 dev $interfaz1 metric 2 gw $porH116
route add -net $gualeguay netmask $Netmask24 dev $interfaz1 metric 1 gw $porH116
route add -net $hernandarias netmask $Netmask26 dev $interfaz1 metric 2 gw $porH116
route add -net $bululu netmask $Netmask30 dev $interfaz1 metric 2 gw $porH116


